package com.itheima.sh.service;

import com.itheima.sh.dao.UserMapper;
import com.itheima.sh.pojo.User;
import com.itheima.sh.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class UserServiceImpl {
    private static SqlSession sqlSession;
    private static UserMapper mapper;

    static {
        sqlSession = SqlSessionUtil.getSqlSession();
        mapper = sqlSession.getMapper(UserMapper.class);
    }

    public List<User> queryAllUsersByPage(int startIndex, int pageSize) {
        List<User> list = mapper.queryAllUsersByPage(startIndex, pageSize);
        sqlSession.close();
        return list;
    }


    public void updateUser(User user) {
        mapper.updateUser(user);
    }

    public void deleteRole(int id) {
        mapper.deleteRole(id);
    }

    public void addRoles(int id, Integer roleIndex) {
        mapper.addRoles(id, roleIndex);
    }
}







